package org.nanotek.tika.tests;

import nl.flotsam.xeger.Xeger;

import org.apache.lucene.index.IndexWriter;
import org.nanotek.dao.DAO;
import org.nanotek.util.StringDistance;
import org.springframework.batch.core.JobParametersInvalidException;
import org.springframework.batch.core.launch.JobExecutionNotRunningException;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.launch.NoSuchJobExecutionException;
import org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;
import org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;
import org.springframework.batch.core.repository.JobRestartException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.sun.syndication.feed.atom.*;
public class LinkDAOTest {

	private static ClassPathXmlApplicationContext ctx;

	/**
	 * @param args
	 * @throws JobParametersInvalidException 
	 * @throws JobInstanceAlreadyCompleteException 
	 * @throws JobRestartException 
	 * @throws JobExecutionAlreadyRunningException 
	 * @throws NoSuchJobException 
	 * @throws JobExecutionNotRunningException 
	 * @throws NoSuchJobExecutionException 
	 */
	@SuppressWarnings("unchecked")
	public static void main(String[] args)  {
		ctx = new ClassPathXmlApplicationContext(new String[] {
		"database-loaders/spring-dao-context.xml"});
		int i = 0;
		try {
			DAO<Link> dao = (DAO<Link>) ctx.getBean("linkDAO");
			Link link = new Link(); 
			link.setHref("HREF"); 
			link.setLength(200); 
			link.setTitle("TITLE"); 
			link.setType("TYPE");
			link.setRel("REAL"); 
			link.setHreflang("LANG"); 
			link.setHrefResolved("hrefResolved");
			dao.update(link);
		}catch (Throwable ex) 
		{ 
			System.out.println(i);
			ex.printStackTrace();
		}
	}

	Integer getRandomLen () 
	{  
		String valStr =  String.valueOf(new Double(Math.random()).floatValue());
		valStr = valStr.substring(0, 2);
		return new Integer(valStr);
	}
	
//	int LevenshteinDistance(String s, String t)
//	{
//		int len_s = s.length(); 
//		int len_t = t.length(); 
//		int cost = 0;
//
//	  if(s[0] != t[0]) then cost = 1
//
//	  if(len_s == 0) then      return len_t
//	  elseif(len_t == 0) then  return len_s
//	  else                     return minimum(LevenshteinDistance(s[1..len_s-1], t) + 1,
//	                                          LevenshteinDistance(s, t[1..len_t-1]) + 1,
//	                                          LevenshteinDistance(s[1..len_s-1], t[1..len_t-1]) + cost)
//	}
	
}
